package uvt.map.graph;

import java.util.ArrayList;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;

import org.openstreetmap.gui.jmapviewer.Coordinate;

import uvt.map.JMapViewer;
import uvt.map.graph.element.Station;
import uvt.map.mapmarker.MapMarkerDot;

public class Node extends Station implements Drawable {
	
	private TreeMap<String,Coordinate> coordList;
	private ArrayList<Node> nextList;
	
	public Node() {
		coordList = new TreeMap<String,Coordinate>();
	}
	
	public Node(String name,double lat,double lon) {
		setName(name);
		setLatitude(lat);
		setLongitude(lon);
		coordList = new TreeMap<String,Coordinate>();
	}
	
	public void draw(JMapViewer map) {
		map.addMapMarker(new MapMarkerDot(getName(),
				                          new Coordinate(getLatitude(),
				                                         getLongitude()),
				                          8 + map.getZoomSlider().getValue() - 19));
	}
	
	public void addCoordinate(String route,Coordinate coord) {
		coordList.put(route,coord);
	}
	
	public void addNodeInNextList(Node node) {
		nextList.add(node);
	}
	
	public void setCoordinatesForRoute(String route) {
		Coordinate coord = coordList.get(route);
		this.setLatitude(coord.getLat());
		this.setLongitude(coord.getLon());
	}
	
	public Coordinate getCoordinate() {
		return new Coordinate(getLatitude(),getLongitude());
	}
	
	public Coordinate getCoordinateFor(String route) {
		return coordList.get(route);
	}
	
	public void toString2() {
		System.out.println(this.getName() + "\n");
		Set<Entry<String,Coordinate>> ls = coordList.entrySet();
		for(Entry e : ls) {
			System.out.println(e.getKey() + " " + e.getValue() + "\n");
		}
		System.out.println();
	}

}
